package forms;
import images.GetImage;
import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
@SuppressWarnings("serial")
public class FormStart extends JFrame{
	private JTextField txtUser=new JTextField(10);
	private JPasswordField txtPass=new JPasswordField(10);
	private JButton btLogin=new JButton("Sign in");
	private JButton btLogup=new JButton("Sign up");
	
	private void addAction(){
		this.addWindowListener(new WindowAdapter(){
			public void windowClosing(WindowEvent we){
				System.exit(0);
			}
		});
		btLogup.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent ae){
				new FormSignup(FormStart.this).setVisible(true);
			}
		});
	}
	private void loadGUI(){
		JPanel p1=new JPanel(new FlowLayout());
		add(new JLabel(new GetImage().getIcon("chat.png")),BorderLayout.NORTH);	
		p1.add(new JLabel("To use service, please login"));
		p1.add(new JLabel("Nick name"));
		p1.add(txtUser);
		p1.add(new JLabel("Password"));
		p1.add(txtPass);
		
		add(p1,BorderLayout.CENTER);
		
		JPanel p2=new JPanel(new FlowLayout());
		p2.add(btLogin);
		p2.add(btLogup);
		add(p2,BorderLayout.SOUTH);
		setSize(220,350);
		setResizable(false);
		setLocation(400,150);
		
	}
	public FormStart(){
		super("Chat service");
		loadGUI();
		addAction();	
	}
	public void setUserPassword(String user,String password){
		txtUser.setText(user);
		txtPass.setText(password);
	}
	public static void main(String[] args) {
		new FormStart().setVisible(true);
	}
}
